$(function(){

    //common
    ;(function(){
        var iBShare = {
            //初始化
            init: function() {
                var $shareBox = $(".bshare-custom");
                //加载分享工具
                var tools = '';
                tools = '<a title="分享到QQ空间" class="bshare-qzone"></a>';
                tools += '<a title="分享到腾讯微博" class="bshare-qqmb"></a>';
                tools += '<a title="分享到新浪微博" class="bshare-sinaminiblog"></a>';
                tools += '<a title="分享到微信" class="bshare-weixin"></a>';
//		        tools += '<a title="分享到人人网" class="bshare-renren"></a>';
//		        tools += '<a title="分享到网易微博" class="bshare-neteasemb"></a>';
//		        tools += '<a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a>';
                $shareBox.append(tools);
                //绑定分享事件
                $shareBox.children("a").click(function() {
                    var parents = $(this).parent();
                    bShare.addEntry({
                        title: parents.attr("title"),
                        url: parents.attr("url"),
                        summary: parents.attr("summary"),
                        pic: parents.attr("pic")
                    });
                });
            }
        };

        var url=location.search;

        var Request = new Object();
        if(url.indexOf("?")!=-1){
            var str = url.substr(1);
            strs = str.split("&");
            for(var i=0;i<strs.length;i++){
                Request[strs[i ].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        var id = Request["id"];

        $.ajax({// hxclub/articledetail/list.do
            url:'hxclub/articledetail/byIdContent.do?id='+id,
            async:false,
            data:{id:id},
            dataType:"json",
            success:function(json){
                //json = JSON.parse(json);
                var XHtml=template('xScr', json);
                $('#xCont').html(XHtml);

                iBShare.init();

                var id=json.data[0].id;
                var cid=json.data[0].cid;
                tab(id, cid, 'x7Scr', '#x7List');
            }
        })
    })();

    function tab(id, cid, addressT, addressH){
        $.ajax({// hxclub/article/relationlist.do?id=4&cid=101 ;  data/x7List.json data/x7List.json
            url:'hxclub/article/relationlist.do',
            async:false,
            type:'POST',
            data:{cid:cid, id:id},
            success:function(json){
                //alert(JSON.parse(json));
                json = JSON.parse(json);
                var XHtml=template(addressT, json.data);
                $(addressH).html(XHtml);
            }
        })
    }
});
